import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import ElementPlus from "element-plus";
import "element-plus/lib/theme-chalk/index.css";
import "../static/css/global.css";
import io from "socket.io-client";
import { Api } from "./api/api.js";
import { GJ_nowTime } from "../static/js/tool.js";
let a = "http://localhost:9527";
// let a = "http://119.45.124.76:9527";
let socket = io(a, {});
let app = createApp(App)
app.use(store).use(router).use(ElementPlus).mount("#app");
app.config.globalProperties.$socket = socket;

app.config.errorHandler = function (err) {
    let { message, name, row, col, stack } = err;
    let errorDetails = (stack + "").split("at");

    let errorObj = {
        //错误类型
        errorType: name,
        //错误描述
        errorMessage: message,
        //行号
        errorRow: row,
        //列号
        errorCol: col,
        errorCreateTime: GJ_nowTime("date-time", "-"),
        //详细信息
        errorDetails: errorDetails
    }
    Api.addError(errorObj).then((res) => {
        if (res.data) {
            console.log("异常已上传服务器");
        }
    })
}
